package com.rohoo.framework.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionDatabase {
	
	private Connection connection;
	private String database;
	private String username;
	private String password;
	private String url = new String();
	public ConnectionDatabase(){}
	
	public Connection getConnection() throws SQLException{
		url = "jdbc:mysql://localhost/"+database+"?user="+username+"&password="+password; 
		connection = DriverManager.getConnection(url);
		return connection;
	}
	
	public void freeConnection(Connection connection){
		if(connection!=null){
			connection=null;
		}
	}

	public String getDatabase() {
		return database;
	}

	public void setDatabase(String database) {
		this.database = database;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
}